<!DOCTYPE html>
<html>

<head>
	<meta charset="utf-8">
	<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
	<title>社医堂</title>
	<link rel="stylesheet" type="text/css" href="../../../css/api.css" />
	<link rel="stylesheet" type="text/css" href="../../../css/hui.css" />
	<link rel="stylesheet" type="text/css" href="../../../css/iconfont.css" />
</head>

<body>
<style>
table tr td {
	padding: 10px;
}

#num {
	width: 100px;
	border: solid 1px #ccc;
	text-align: center;
	font-size: 25px;
}

body {
	background-color: #fff;
}
.list {
	border: solid #ddd 1px;border-radius: 5px;width: 97%;margin-left: 3%;margin-top: 15px;background-color: aliceblue;
	box-shadow: 3px 3px 3px #ccc;
}

table {}
table tr td { padding: 5px; }
</style>

<div class="hui-wrap">

	<div class="hui-wrap" id="record_2">
		<div class="hui-list" style="background:#FFFFFF;margin-top:3px;padding-right:10px;">
			<ul id="list">
	
			</ul>
		</div>
	</div>

</div>


<script src="../../../script/hui.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../script/hui-tab.js" type="text/javascript"></script>
<script src="../../../script/api.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../script/stm.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
apiready = function () {

	$api.setStorage('curpage',1);
	list(1);
	api.setRefreshHeaderInfo({
		visible : true,
		bgColor : 'rgba(0,0,0,0)',
		textColor : '#666',
		textDown : '下拉刷新',
		textUp : '释放刷新'
	}, function(ret, err) {
		api.refreshHeaderLoadDone();
		list(1);
	});

	api.addEventListener({
		name:'scrolltobottom',
		extra:{
			threshold:0 //设置距离底部多少距离时触发，默认值为0，数字类型
		}
		
	}, function(ret, err){

		$api.setStorage('curpage',parseInt($api.getStorage('curpage'))+1)
		var page = parseInt($api.getStorage('curpage'));
		list(page);

	});

};	

function list(page) {

	api.showProgress({title: '努力加载中...',text: '先喝杯茶...',modal: false});
	api.ajax({
		url: $api.getStorage('geturl') + '&c=ajaxmember&a=appointmentlist',
		method: 'post',
		data: {
			values: { 
				docid: $api.getStorage('userid'),
				page : page
			}
		}
	},function(res, err){
		//console.log(JSON.stringify(res))
		if (res) {			
			if (res.status==1) {
				
				//数据上报
				var updata = ''
				for (i = 0; i < res.data.length; i++) {
					updata += '<div class="list"><table style="width:100%" onClick="tip('+res.data[i].id+')">'
					updata += '<tr><td style="font-size:16px;">姓名：' + res.data[i].name + ' <font style="float:right">电话：' + res.data[i].tel + '</font></td></tr>'
					updata += '<tr><td style="font-size:16px;color:#f00;">备注：' + res.data[i].memo + '</td></tr>'
					updata += '<tr><td style="font-size:16px;color:#00f;">处理：' + res.data[i].result + '</td></tr>'
					updata += '<tr><td style="font-size:16px;">上门时间：' + res.data[i].appointmenttime + '</td></tr>'
					updata += '<tr><td style="font-size:16px;">预约时间：' + res.data[i].addtime + '</td></tr>'					
					updata += '</table></div>'
				}
				if(updata==''){
					api.toast({ msg:'没有更多数据了',location:'top' })
				}
				if(page==1){
					hui("#list").html(updata);
				}else{
					$api.append($api.byId("list"),updata);
				}
				
				
			}else{
				api.toast({ msg:res.tip,location:'top' })
			}
		} else {
			alert( JSON.stringify( err ) );
		}
	}); 
	api.hideProgress();

}



function tip(id){

	hui.prompt('您确认要这处理吗？', ['取消','确定'], function(name){
		//hui.toast('您输入了 :' + name);
		api.ajax({
			url: $api.getStorage('geturl')+'&c=ajaxmember&a=updateappointment',
			method: 'post',
			data: {
				values: {					
					docid  : $api.getStorage('docid'),
					id     : id,
					result : name
				}
			}
		},function(ret, err){
			if (ret) {         
				api.toast({ msg:ret.tip,location:'middle' })
				setTimeout("reload()",1000)
			} else {
				alert( JSON.stringify( err ) );
			}
		});
	}, 
	'例如 : 张三', 
	'已联系本人处理',
	function(){
		//hui.toast('您点击了取消')
	});
}
</script>

</body>
</html>